
//////////////////////////////////////////////////////////////////////////////
// Standard includes
// SystemC includes
// ArchC includes

#include "ac_tlm_rot.h"

//////////////////////////////////////////////////////////////////////////////

/// Namespace to isolate memory from ArchC
using user::ac_tlm_rot;

/// Constructor
ac_tlm_rot::ac_tlm_rot( sc_module_name module_name) :
  sc_module( module_name ),
  target_export("iport1"),
  target_export2("iport2"),
  target_export3("iport3"),
  mem_port("mem_port", 5242880U),
  mul_port("mul_port", 48U),
  add_port("add_port", 48U),
  exp_port("exp_port", 24U),
  div_port("div_port", 48U),
  srt_port("srt_port", 18U),
  lck_port("lck_port", 8U)

{
  target_export( *this );
  target_export2( *this );
  target_export3( *this );
}

/// Destructor
ac_tlm_rot::~ac_tlm_rot() {

}

// Change endianess
uint32_t ac_tlm_rot::changeEndianess(uint32_t data) {
    union word_t {
    uint32_t b;
    char c[4];
  } ;

  word_t word_request;
  word_t word_new_request;

  word_request.b = data;

  for(int i = 0; i < 4; i++) {
    word_new_request.c[i] = word_request.c[3-i];
  }
  return word_new_request.b;
}
